/**
 * 
 */
package org.dragonfire.editor.syntax.rules;

import org.eclipse.jface.text.rules.ICharacterScanner;
import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.Token;

/**
 * @author Darth Android
 * @date Oct 2, 2007
 */
public class SingleCharRule implements IRule {

	private IToken token;
	private String chars;

	public SingleCharRule(IToken token, String chars) {
		this.token = token;
		this.chars = chars;
	}

	public IToken evaluate(ICharacterScanner scanner) {
		if (chars.contains((char) scanner.read() + ""))
			return token;
		scanner.unread();
		return Token.UNDEFINED;
	}
}
